import dto.User;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.SimpleFormatter;

public class work2 {
    public static List<User> users = new ArrayList<>();

    public static void main(String[] args) throws ParseException {
        String userStrs = "10001:张三:男:1990-01-01#10001:张三:男:1990-01-01#10001:张三:男:1990-01-01#10002:李四:女:1989-01-09#10003:王五:男:1999-09-09#10004:刘备:男:1899-01-01#10005:孙悟空:男:1900-01-01#10006:张三:女:1999-01-01#10007:刘备:女:1999-01-01#10008:张三:女:2003-07-01#10009:猪八戒:男:1900-01-01";
        String[] userInfos = userStrs.split("#");
        for (String userInfo : userInfos) {
            System.out.println(userInfo);
            DateTimeFormatter sf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
            String[] userIn = userInfo.split(":");
            users.add(new User(Long.parseLong(userIn[0]), userIn[1], userIn[2], LocalDate.parse(userIn[3], sf)));
        }
        System.out.println(users);
        Map<String,Integer> count = new HashMap<>();
        for (User user : users) {
            count.put(user.getName(),count.getOrDefault(user.getName(),0) + 1);
        }
        System.out.println(count);
    }
}
